import { request } from "@/utils/service"

export interface IPosterTemplate {
  id?: number
  posterName: string
  posterContentUri: string
  posterImg: string
  posterType: number
  posterTemplateNo: string
  userNumber: number
}

export interface ICreatePosterTemplateDataApi {
  posterName: string
  posterContentUri: string
  posterImg: string
  posterType: number
  paid: boolean
}

export interface IGetPosterTemplateListDataApi {
  posterType?: number
  posterName?: string
  pageNum: number
  pageSize: number
}

export function createPosterTemplate(data: ICreatePosterTemplateDataApi) {
  return request({
    url: "/travel/manage/poster/template/create",
    method: "post",
    data
  })
}

export function getPosterTemplateList(params: IGetPosterTemplateListDataApi) {
  return request({
    url: "/travel/manage/poster/template/list",
    method: "get",
    params
  })
}
export function updatePosterTemplate(id: number, data: ICreatePosterTemplateDataApi) {
  return request({
    url: "/travel/manage/poster/template/update/" + id,
    method: "post",
    data
  })
}

export function deletePosterTemplate(id: number) {
  return request({
    url: "/travel/manage/poster/template/delete/" + id,
    method: "delete"
  })
}

interface IPosterType {
  id?: number
  typeName: string
}

interface ICreatePosterTypeDataApi {
  typeName: string
}

type IChangePosterTypeNameDataApi = ICreatePosterTypeDataApi

interface IGetPosterTypeListDataApi {
  /** 当前页码 */
  pageNum: number
  /** 查询条数 */
  pageSize: number
}

export function createPosterType(data: ICreatePosterTypeDataApi) {
  return request({
    url: "/travel/manage/poster/template/type/create",
    method: "post",
    data
  })
}

export function changePosterTypeName(id: number, data: IChangePosterTypeNameDataApi) {
  return request({
    url: "/travel/manage/poster/template/type/update/" + id,
    method: "put",
    data
  })
}

export function getPosterTypeList(params: IGetPosterTypeListDataApi) {
  return request({
    url: "/travel/manage/poster/template/type/list",
    method: "get",
    params
  })
}
